import { usePiniaStore } from "../store"

export const getHurt = (attack,defence)=>{
	// 随机修正系数
	let randomCorrectionFactor =parseInt(Math.random()*39+217)/255  //217-255随机浮动 //浮点型
	let benxi = 1.0
	if(attack.ji_neng.shu_xing_No==attack.shu_xing_No){
		benxi = 1.1
	}
	let gongji = 1
	let fangyu = 2
	if(attack.ji_neng.style.includes("特攻")){
		gongji = 3
		fangyu = 4
	}else if(attack.ji_neng.style.includes("攻击")){
		gongji = 1
		fangyu = 2
	}
	let kezhi = 0
	let store = usePiniaStore()
	store.base_shu_xing.data.forEach(item=>{
		if(item.No==attack.shu_xing_No){
			if(item.counter.includes(defence.shu_xing_No)){
				kezhi = 2
			}
			if(item.counteracted.includes(defence.shu_xing_No)){
				kezhi = 0.5
			}
		}
	})
	// 伤害计算公式 ((攻击方等级*0.4)*技能威力*攻击方攻击/防御值/50)*本系加成 * 克制系数 * 修正系数
	let hurt = ((attack.level*0.4)*attack.ji_neng.weili*attack.shu_xing[gongji]/defence.shu_xing[fangyu]/50)*benxi*kezhi*randomCorrectionFactor
	return Number(hurt.toFixed(0))
	
	// 暂定本系加成1.1  非本系1.0
	// attack.shu_xing_zhi = [血量，攻击,防御，特攻，特防，速度]
	// attack.status = [麻痹、中毒、睡眠、灼伤、冻结、寄生、疲惫]
	// defence.shu_xing_zhi = [血量，攻击,防御，特攻，特防，速度]
	// defence.status = [麻痹、中毒、睡眠、灼伤、冻结、寄生、疲惫]
	
}